home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11382 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: druid.borland.com!usenet
  2. From: pete@borland.com (Pete Becker)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Unable to use 'delete' after 'new'
  5. Date: 23 Mar 1996 17:19:09 GMT
  6. Organization: Borland International
  7. Distribution: inet
  8. Message-ID: <4j1bqd$dpc@druid.borland.com>
  9. References: <4iudtl$eni@lisa.iosphere.net>
  10. NNTP-Posting-Host: pbecker.borland.com
  11. Mime-Version: 1.0
  12. Content-Type: Text/Plain; charset=ISO-8859-1
  13. X-Newsreader: WinVN 0.99.5
  14.  
  15. In article <4iudtl$eni@lisa.iosphere.net>, ianq@sonetis.com says...
  16. >
  17. >I have 2 definitions of new arrays that I allocate that I am unfortunately
  18. >having a hard time deleting afterwards.
  19. >
  20. >1 -     int *iColsize = new int[cCols]; 
  21. >
  22. >The trick here is that I need to return this array to the calling function,
  23. >which then processes the data. 
  24. >
  25. >How do I do the delete from the calling function as opposed to within the
  26. >function the NEW was executed.
  27. >
  28. >I tried the basic delete [] iColsize from the calling function, and got a
  29. >memory exception.
  30. >
  31. >
  32. >2 -     char (*sPassStr)[MAX_COLSIZE + 1] = new
  33. >char[iColsize[0]][MAX_COLSIZE + 1]; 
  34. >
  35. >The problem here lies with an ODBC function I execute.
  36. >
  37. >char (*sPassStr)[MAX_COLSIZE + 1] = new char[iColsize[0]][MAX_COLSIZE + 1];
  38. >SQLBindCol(hstmt, i, SQL_C_CHAR, sPassStr[i], iColsize[i], &cbTemp);
  39. >retcode = SQLFetch(hstmt);
  40. >
  41. >Up until I do the SQLFetch, I can do a 'delete [] sPassStr' fine.
  42. >After the Fetch is executed, if I do a delete, I get a memory exception.
  43.  
  44. You really should post this on comp.lang.c++, not comp.lang.c. Briefly, there's 
  45. nothing in the statement of question 1 that indicates what the problem is. What 
  46. it describes is perfectly legal and works just fine. The problem lies in the 
  47. part that is not described in this message. Question 2 is incomprehensible. 
  48. Learn to use typedefs. They will make your life much easier.
  49.     -- Pete
  50.  
  51.